package com.example.librarymanagementsystembackend.utils;

import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 响应数据
 */
@Data
@Schema(description = "通用响应包装类，包含状态码、消息和数据负载")
public class ResponseData<T> {

    @Schema(
            description = "响应状态码",
            example = "200",
            requiredMode = Schema.RequiredMode.REQUIRED
    )
    private Integer code;

    @Schema(
            description = "人类可读的响应消息",
            example = "操作成功完成",
            requiredMode = Schema.RequiredMode.REQUIRED
    )
    private String message;

    @Schema(
            description = "实际的响应数据负载",
            example = "null",
            requiredMode = Schema.RequiredMode.REQUIRED
    )
    private T data;

    public ResponseData(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}